<template>
	<van-form @submit="onSubmit">
		<van-field v-model="nickname" name="nickname" label="用户名" placeholder="用户名" />
		<van-field v-model="email" name="email" label="请输入email" placeholder="email" />
		<van-field v-model="password" type="password" name="password" label="密码" placeholder="密码" />
		<van-field v-model="password1" type="password" name="password1" label="请再次输入密码" placeholder="两次密码保持一致" />
		<div style="margin: 16px;"><van-button round block type="info" native-type="submit">提交</van-button></div>
	</van-form>
</template>

<script>
	import { Toast } from 'mint-ui';
export default {
	data() {
		return {
			nickname: '',
			password: '',
			password1: '',
			email: '',
		};
	},
	methods: {
		onSubmit(values) {
			if(this.password == this.password1){
				let that = this
				this.$http.post('http://127.0.0.1:8080/register', values, { emulateJSON: true }).then(result => {
					if(result.body.err_code == 0){
						Toast(result.body.message)
						this.$router.push({name:'member'})
					}else{
					Toast(result.body.message)
					}
						
				});
			}else {
				Toast('两次输入密码不符请重新输入');
			}
		}
	}
};
</script>

<style></style>
